"""
#!/usr/bin/python3
# coding:utf-8            
#
# Copyright (C) 2024 - 2024 Jasonakeke， Inc. All Rights Reserved 
# @Desc	   ：当前的命令调用 flask 要和 Web 主程序分离
# @Time    : 2024/11/4 21:09
# @Author  : Code_By_Jasonakeke
# @Email   : 2284037977@qq.com
# @File    : test_command.py
# @IDE     : PyCharm
"""
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
from Shopping import create_app

app = create_app('develop')

manager = Manager(app)
db = SQLAlchemy(app)


class User(db.Model):
	__tablename__ = 't_user'
	id = db.Column(db.Integer, primary_key = True, autoincrement = True)
	name = db.Column(db.String(32), nullable = False)
	password = db.Column(db.String(64), nullable = False)

# db.create_all()

@manager.option('-u', '--username', dest = 'username')
@manager.option('-p', '--password', dest = 'password')
def create_user(username, password):
	user = User(name = username, password = password)
	db.session.add(user)
	db.session.commit()
	print('添加用户成功')
@manager.command
def hello():
	print("hello")


if __name__ == '__main__':
	manager.run()
